window.onload = function(){
    // 鼠标移入
    var mousemove = function(a,b){
        a.onmouseover = function(){
            b.style.display = "block";
        };
        a.onmouseout = function(){
            b.style.display = "none";
        }
    }
    // 定位
    var city = document.getElementById("city");
    var citys = document.getElementById("citys");
    mousemove(city,citys);
   
    // 我的京东
    var myJD = document.getElementById("myJD");
    var myJDS = document.getElementById("myJDS");
    mousemove(myJD,myJDS)

    // 企业采购
    var firm = document.getElementById("firm");
    var firmList = document.getElementById("firmList");
    mousemove(firm,firmList)

    // 客户服务
    var customer = document.getElementById("customer");
    var customerList = document.getElementById("customerList");
    mousemove(customer,customerList)

    // 网站导航
    var webNav = document.getElementById("webNav");
    var webNavList = document.getElementById("webNavList");
    mousemove(webNav,webNavList)

    // 手机京东
    var PhoneJD = document.getElementById("PhoneJD");
    var JDcode = document.getElementById("JDcode");
    mousemove(PhoneJD,JDcode)
    

    var items = document.getElementsByClassName("item");
    var cityShow = document.getElementById("cityShow");

    for( let i=0 ; i<items.length; i++ ){
        
        items[i].addEventListener("click",function(){
            for(let j =0 ; j<items.length;j++){
                // console.log(items[j]);
                items[j].style.color = "#ac99a3";
                items[j].style.backgroundColor = "#fff";
            }
            items[i].style.backgroundColor = "red";
            items[i].style.color = "#fff";
            cityShow.innerHTML = items[i].innerHTML;
            
        })
    }

    // var JDlogo = document.getElementById("JDlogo");
    // var imglog = document.getElementById("imglog");
    // var logoScene = document.getElementById("logoScene");

    // JDlogo.addEventListener("mouseover",function(e){
    //     imglog.style.zIndex = 1;
    //     logoScene.style.backgroundImage = "url('../images/logo/eef283b0ed619fe4.gif')"
    //     setTimeout(function (e){
    //         document.getElementsByClassName("logo_text")[0].style.display = "block"
       
    //     }, 4000);
    //     e.stopPropagation();
        
    // })
    
    // JDlogo.onmouseout =function(){
    //     imglog.style.backgroundImage = "url('../images/logo/sprite.png')"
    //     document.getElementsByClassName("logo_text")[0].style.display = "none"
    // }
    var goodsImg = document.getElementById("goods_imgs")
    let i =0;
    var imgArr = [
        "url('../images/q.jpg')",
        "url('../images/img1.jpg')",
        "url('../images/p6.jpg')",
        "url('../images/q (1).jpg')",
        "url('../images/q 2.jpg')",
        "url('../images/q 3.jpg')",
        "url('../images/q 4.jpg')",
        "url('../images/q 5.jpg')"
    ]
    setInterval(()=>{
        if( i < imgArr.length){
            goodsImg.style.backgroundImage =  imgArr[i++];
            // console.log(imgArr[i++]);
        }else{
            i = 0;
        }
    },3000) 

    
    
    // 滚动出现固定搜索
    var top_search = document.getElementById("top_search");
    var top = document.getElementsByTagName("body")[0];

    document.addEventListener( "scroll",function(){
        
        let scrollTop = document.documentElement.scrollTop;
        // console.log(scrollTop);
        if(scrollTop >= 617){
            top_search.style.height = "50px"
            top_search.style.transition = "1s"
            top_search.style.visibility = "visible";
            
        }else{
            top_search.style.transition = "0s";
            top_search.style.height = "0px";
            top_search.style.visibility = "hidden"
           
        }

     })



     var special = document.getElementsByClassName("special_chooes")[0];
     console.log(special);
     for(let i = 0 ;i<special.children.length;i++){
        
        special.children[i].onmouseover = function(){
            for(let j = 0;j<special.children.length;j++){
                special.children[j].style.color ="rgb(153,153,153)"
                special.children[j].style.borderBottom= " 0px solid red";
                document.getElementsByClassName("special_list_a")[j].style.display = "none"
            }
            special.children[i].style.color ="#e1251b"
            special.children[i].style.borderBottom= " 2px solid red";
            document.getElementsByClassName("special_list_a")[i].style.display = "block"

        }
        
     }



     
}